<template>
	<view class="page tn-safe-area-inset-bottom" :style="{paddingTop: vuex_custom_bar_height + 'px'}">
		<view class="top-bg"></view>
		<dawnBar title="病案复印"></dawnBar>
		<view class="page-container">
			<view class="tn-margin-top-sm menu-nav__container tn-flex tn-flex-wrap tn-flex-col-center tn-flex-row-between">
				<view @click="nav('/hosp/medicalcopy/form')"
					class="dawn-shadow menu-nav__item tn-flex tn-flex-direction-row tn-flex-col-center tn-flex-row-between tn-color-white">
					<view
						class="menu-nav__item__left tn-flex tn-flex-direction-row tn-flex-col-center tn-flex-row-center">
						<view
							class="menu-nav__item__left--icon tn-flex tn-flex-col-center tn-flex-row-center tn-shadow-blur tn-main-gradient-blue--light">
							<view class="tn-icon-image-text-fill"></view>
						</view>
						<view class="menu-nav__item__left__content">
							<view class="menu-nav__item__left__content--title">
								病案复印
							</view>
							<view class="menu-nav__item__left__content--data">
								病案复印申请
								<text class="tn-icon-right tn-padding-left-xs"></text>
							</view>
						</view>
					</view>
					<view class="menu-nav__item__right">
						<view class="menu-nav__item__right--icon">
							<view class="tn-icon-edit-form"></view>
						</view>
					</view>
				</view>


				<view @click="nav('/hosp/medicalcopy/list')"
					class="dawn-shadow menu-nav__item tn-flex tn-flex-direction-row tn-flex-col-center tn-flex-row-between tn-color-white">
					<view
						class="menu-nav__item__left tn-flex tn-flex-direction-row tn-flex-col-center tn-flex-row-center">
						<view
							class="menu-nav__item__left--icon tn-flex tn-flex-col-center tn-flex-row-center tn-shadow-blur tn-main-gradient-indigo--light">
							<view class="tn-icon-menu-list-fill"></view>
						</view>
						<view class="menu-nav__item__left__content">
							<view class="menu-nav__item__left__content--title">
								我的申请
							</view>
							<view class="menu-nav__item__left__content--data">
								申请历史
								<text class="tn-icon-right tn-padding-left-xs"></text>
							</view>
						</view>
					</view>
					<view class="menu-nav__item__right">
						<view class="menu-nav__item__right--icon">
							<view class="tn-icon-search-menu-fill"></view>
						</view>
					</view>
				</view>
			</view>

			<view class="tn-margin-top-sm tn-margin-bottom-sm"  v-if="articleList.length > 0">
				<view class="tn-flex tn-padding-top-sm tn-flex-row-between">
					<view class="justify-content-item tn-text-bold tn-text-xl">
						<text class="tn-icon-notice-fill"></text>
						<text class="">公告</text>
					</view>
				</view>
				<view class="">
					<block v-for="(item, index) in articleList" :key="index">
						<view @click="newsDteail(item)"
							class="tn-bg-white dawn-shadow dawn-radius tn-margin-top-sm dawn-radius">
							<view class="tn-flex">
								<view v-if="item.coverImg" class="news-image-box tn-margin-sm"
									:style="'background-image:url(' + item.coverImg + ')'">
									<view class="news-image-pic"></view>
								</view>
								<view class="tn-margin-sm tn-padding-top-xs" style="width: 100%;">
									<view class="tn-text-lg tn-text-bold news-title">
										{{ item.title }}
									</view>
									<view class="tn-padding-top-xs">
										<text class=" tn-text-sm tn-color-gray news-desc">
											{{ item.description }}
										</text>
									</view>
									<view class="tn-flex tn-flex-row-right tn-flex-col-between tn-padding-top-xs">
										<!-- <view v-for="(label_item,label_index) in item.tagsArray" :key="label_index"
											class="justify-content-item tn-tag-content__item tn-margin-right tn-round tn-text-sm tn-text-bold"
											:class="[`tn-bg-${item.color}--light tn-color-${item.color}`]">
											<text class="tn-tag-content__item--prefix">#</text> {{ label_item }}
										</view> -->
										<view class="justify-content-item tn-color-gray tn-text-center tn-color-gray"
											style="padding-top: 5rpx;">
											<text class="tn-icon-footprint tn-padding-right-xs"></text>
											<text class="tn-padding-right">{{ item.views }}</text>
											<text class="tn-icon-time-fill tn-padding-right-xs"></text>
											<text class="">{{ formatDate(item.createTime) }}</text>
										</view>
									</view>
								</view>
							</view>
						</view>
					</block>
				</view>
			</view>


		</view>
	
		<!-- 悬浮按钮-->
		<view class="tn-flex tn-flex-direction-column tn-footerfixed">
			<view class="tn-flex tn-flex-direction-column tn-flex-col-center tn-flex-row-center tn-padding-xl">
				<image class="hosp-image" mode="widthFix" :src="appConfig.logoUrl"></image>
				<view class="tn-margin-top-sm">
					<text class="dawn-text-lg tn-text-bold">{{ appConfig.appTitle || ''}}</text>
				</view>
			</view>
			<view class="tn-flex tn-flex-col-center tn-flex-row-center tn-width-full">
				<view class="tn-margin-bottom-lg">
					<text class="tn-margin-right-ss">病案复印咨询电话</text>
					<text 
						class="tn-icon-tel-circle-fill tn-margin-right-ss"></text>
					<text @click="callPhoneNumber(collectAddress[0].value)" v-if="collectAddress.length > 0" class="dawn-text-sm">{{ collectAddress[0].value  || '' }}</text>
					<text @click="callPhoneNumber(appConfig.companyRespVO.phone)" v-else class="dawn-text-sm">{{ appConfig.companyRespVO.phone  || '' }}</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import page_mixin from '@/mixins/page_mixin.js'
	import dayjs from '@/plugin/dayjs/dayjs.min.js';
	import * as Util from '@/utils/util.js';
	import * as ArticleApi from '@/api/cms/article.js';
	import * as api from '@/api/api.js';
	import * as config from "@/api/config.js";

	import chs from "@/libs/chs.js";
	import {
		toLogin
	} from '@/libs/login.js';
	import {
		mapGetters
	} from "vuex";
	const app = getApp();

	export default {
		name: 'order',
		mixins: [page_mixin],
		computed: mapGetters(['appConfig', 'uid', 'isLogin', 'userInfo', 'patientInfo']),
		data() {
			return {
				iconSize: 38,
				size: 40,
				loading: false,
				show: false,
				msg: '',
				dawnMsgBox: '',
				success: 0,
				successTitle: '正在处理中，请稍候...',
				articleList: [],
				dictData: {},
				collectAddress: []
			}
		},
		async onLoad(options) {
			await this.$onLaunched;
			console.info("order return options");
			console.table(options);
			if (!this.isLogin) {
				toLogin();
				return;
			}
			this.initData();
		},
		methods: {
			initData: function() {
				let that = this;
				ArticleApi.getArticlePage({
					categoryKey: config.CMS_TYPE.MEDICAL_NOTICE
				}).then(res => {
					console.table(res)
					if (res.code === 0) {
						const l = res.data.list || [];
						if (l.length > 0) {
							that.$set(this, 'articleList', l);
							// l.forEach(function(item) {
							// 	if(item.tags === '病案复印'){
							// 		that.articleList.push(item);
							// 	}
							// });
						}
					}
				});
				
				api.getDictDataListByBiz(config.DICT_TYPE.BIZ_MEDICAL_COPY).then(res => {
					if (res.code === 0) {
						that.$set(this, 'dictData', res.data);
						that.collectAddress = that.dictData[config.DICT_TYPE.COLLECT_ADDRESS];
					}
				});
			},
			formatDate: function(date) {
				return dayjs(date).format("YYYY-MM-DD");
			},
			fen2yuan(price) {
				return Util.fen2yuan(price)
			},
			formatDateTime: function(date) {
				return dayjs(date).format("YYYY-MM-DD HH:mm:ss");
			}
		}
	}
</script>

<style lang="scss" scoped>
	.hosp-image {
		// background-color: #E6E6E6;
		margin-right: 0rpx;
		width: 160rpx;
		height: 160rpx;
		border-radius: $dawn-border-radius;
	}
</style>